local skel = fk.CreateSkill {
  name = "emo__yuanzigns",
  tags = {Skill.Compulsory}
}

skel:addEffect(fk.Damaged, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player and data.to then
      return table.find(player.room.alive_players, function (p)
        return not p:isAllNude()
      end)
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p)
      return not p:isAllNude()
    end)
    local tos = room:askToChoosePlayers(player, {
      min_num = 1, max_num = 1, skill_name = skel.name, targets = targets,
      prompt = "#emo__yuanzigns-choose",
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]---@type ServerPlayer
    local cards = {}
    local prompt = "#emo__yuanzigns-card"
    if to == player and #player:getCardIds("j") == 0 then
      cards = room:askToCards(player, {
        min_num = 1, max_num = 999, include_equip = true, cancelable = false, skill_name = skel.name, prompt = prompt,
      })
    else
      cards = room:askToChooseCards(player, {
        target = to, flag = "hej", min = 1, max = 999, cancelable = false, skill_name = skel.name, prompt = prompt,
      })
    end
    room:recastCard(cards, to, skel.name)
  end,
})


Fk:loadTranslationTable{
  ["emo__yuanzigns"] = "原子概念神",
  [":emo__yuanzigns"] = "锁定技，当你受到伤害后，你重铸一名角色区域内的任意张牌。",

  ["#emo__yuanzigns-choose"] = "选择一名角色，你重铸其区域内的任意张牌",
  ["#emo__yuanzigns-card"] = "重铸其区域内的任意张牌",
}

return skel
